package com.taritari.controller;

import com.taritari.service.ContentService;
import com.taritari.vo.ContentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @ClassName ContentController
 * @Description TODO
 * @date 2021/9/30 15:38
 * @Version 1.0
 */
@RestController
public class ContentController {
    @Autowired
    private ContentService contentService;
    @GetMapping("/parse/{keywords}")
    public Boolean parse(@PathVariable("keywords") String keywords) throws IOException {
        return contentService.parseContent(keywords);
    }
    @GetMapping("search/{keywords}/{pageNo}/{pageSize}")
    public List<Map<String ,Object>> search(@PathVariable("keywords")String keywords,
                                            @PathVariable("pageNo")int pageNo,
                                            @PathVariable("pageSize")int pageSize) throws IOException {

        List<Map<String, Object>> search = contentService.search(keywords, pageNo, pageSize);
        return search;
    }
    @PostMapping("/getGoods")
    public List<Map<String, Object>> getGoods(@RequestBody ContentVo vo) throws IOException {
        List<Map<String, Object>> goods = contentService.getGoods(vo);
        return goods;
    }
}
